<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var n2 = 0
        var res = 0
        for (var i = 1; i <= 9; i++) {
            for (var n = 1; n <= i + 1; n++) {
                n2 = n2 * 10 + i
                console.log(n2)
                res += n2
            }
            n2 = 0
        }
        console.log('叠数之和(1-9)是' + res)
    </script>
</body>

</html>